You list running containers using the docker ps command, which shows all active containers with their IDs, names, images, status, and port mappings.
The docker ps command is the primary tool for listing Docker containers. Without any flags, it displays only running containers, showing essential information such as container ID, image used, command being executed, creation time, current status, port mappings, and container name. For debugging or auditing purposes, you can expand this view to include stopped containers or format the output for scripting.
The -a or --all flag is crucial when you need to see stopped containers, which are not shown by default. Stopped containers consume disk space and can accumulate over time. The -q flag returns only numeric container IDs, which pairs well with other commands like docker stop $(docker ps -q) to stop all running containers, or docker rm $(docker ps -a -q) to clean up all stopped containers.
Docker's filtering capability (--filter) allows you to narrow results by various criteria: status (running, exited, paused), name, label, network, or exited code. For example, docker ps --filter "exited=1" shows containers that exited with error code 1. You can combine multiple filters to refine results further.
docker ps - Quick check of what's currently running
docker ps -a - See all containers, including stopped ones (disk usage)
docker ps -a --size - Check disk space consumed by containers
docker ps -q - Get IDs for scripting (e.g., docker stop $(docker ps -q))
docker ps --filter "name=postgres" - Find containers related to a specific service
docker ps --format "table {{.Names}}\t{{.Image}}" - Clean output for monitoring dashboards
The output columns include: CONTAINER ID (shortened unique identifier), IMAGE (image name:tag), COMMAND (command being executed), CREATED (time since creation), STATUS (running, exited, etc.), PORTS (port mappings), and NAMES (container names). The STATUS column is particularly useful for understanding container health—Up 2 minutes indicates healthy operation, while Exited (1) 3 hours ago shows a failure with the exit code.